import 'whatwg-fetch';

const fetchData = (url, params, callback) => {
    fetch(url, {
        method: 'POST',
        headers: {'Content-Type': 'text/plain'},
        body: JSON.stringify(params)
    })
    .then( (response) => {
            return response.json();
    })
    .then((result)=>  {
        callback(result)
    })
    .catch((error) => {
        alert('参数错误');
    })
};
export default fetchData;